< previous page page_608 next page >

Page 608
The preceding example shows how you can accomplish the same task with less coding. Even better, this code runs much faster than the walk-through loop shown in Listing 15.5, and this single line of code works for any number of records in the set. Furthermore, if this statement is sent to a back-end database server connected by ODBC and not processed by the local workstation, you could see an even greater increase in processing speed for your program.
Let's start a new program that illustrates the UPDATE_SET statement. Use SQL-VB5 to create a new script file called SQLVB06.SQV and enter the commands in Listing 15.6. After you save the script, execute it and check your results against those in Figure 15.7.
Type.gifListing 15.6. Using the UPDATE_SET statement.
//
// sqlvb06.sqv - testing the UPDATE ... SET statement
//
// create a database
dbMake sqlvb06.mdb;
// create a table
CREATE TABLE EmpTable
   (EmpID TEXT(5) CONSTRAINT PKEmpTable PRIMARY KEY,
    EmpName TEXT(30),
    EmpSalary CURRENCY
   );
// insert some data
INSERT INTO EmpTable VALUES
   ('E001',
    'Anderson, Shannon',
    '35000'
   );
INSERT INTO EmpTable VALUES
   ('E002',
    'Billings, Jesse',
    '30000'
   );
INSERT INTO EmpTable VALUES
   ('E003',
    'Caldwell, Dana',
    '25000'
   );
// show first result set
SELECT * FROM EmpTable AS FirstPass;
// now perform update
UPDATE empTable SET EmpSalary = EmpSalary * 1.175;
// show new results
SELECT * FROM EmpTable AS SecondPass;
// eof

 
< previous page page_608 next page >

If you like this book, buy it!